home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 1.iso / dist / fw_exmh.idb / usr / freeware / lib / exmh-2.5 / pgpOld.tcl.z / pgpOld.tcl
Text File  |  2002-07-08  |  2KB  |  92 lines

  1. # pgpOld.tcl
  2.  
  3. # $Log: pgpOld.tcl,v $
  4. # Revision 1.3  1999/08/22 19:19:22  bmah
  5. # Fix typo that prevented Old PGP->Extract Keys from working.
  6. #
  7. # Revision 1.2  1999/08/03 04:05:55  bmah
  8. # Merge support for PGP2/PGP5/GPG from multipgp branch.
  9. #
  10. # Revision 1.1.4.1  1999/06/14 20:05:16  gruber
  11. # updated multipgp interface
  12. #
  13. # Revision 1.1  1999/06/14 15:14:54  markus
  14. # added files
  15. #
  16. # Revision 1.2  1998/12/02 19:36:26  markus
  17. # Fixed automagic version checking
  18. #
  19. # Revision 1.1.1.1  1998/11/24 22:34:46  markus
  20. # Initial revision
  21. #
  22.  
  23. # decrypt the current message
  24. proc Pgp_Old_Decrypt { } {
  25.     global exmh msg mhProfile exwin pgp
  26.  
  27.     set file $msg(path)
  28.  
  29.     # decide which version to use / implicitely checks for pgp enabled
  30.     if { [catch {Pgp_CheckVersion $file real v} err] } {
  31.         Exmh_Debug "<PGP> $err"
  32.         Exmh_Status "No version found! Perhaps this is no ciphertext."
  33.         return
  34.     }
  35.  
  36.     set pgpfile [Mime_TempFile "decrypt"]
  37.     Exmh_Status "[set pgp($v,fullName)] $exmh(folder)/$msg(id)"
  38.     Pgp_Exec_Decrypt $v $file $pgpfile message [set pgp($v,myname)]
  39.  
  40.     if {$message != {}} {
  41.     Pgp_Misc_DisplayText "[set pgp($v,fullName)] decrypt $exmh(folder)/$msg(id)" $message
  42.     }
  43.     set t $exwin(mtext)
  44.  
  45.     set orig [open $file r]
  46.     if [catch {
  47.     set mess [open $pgpfile r]
  48.     } err] {
  49.     return 0
  50.     }
  51.  
  52.     set outfile [Mime_TempFile "decypted"]
  53.     set comb [open $outfile w 0600]
  54.     while {[gets $orig line] != -1} {
  55.     if {[regexp {^-+BEGIN PGP MESSAGE} $line]} {
  56.         puts -nonewline $comb [read $mess]
  57.         while {[gets $orig line] != -1} {
  58.         if {[regexp {^-+END PGP MESSAGE} $line]} { break }
  59.         }
  60.     } else {
  61.         puts $comb $line
  62.     }
  63.     }
  64.     close $orig
  65.     close $comb
  66.     close $mess
  67.  
  68.     Mh_Rename $outfile $file
  69.     File_Delete $pgpfile
  70.     set msg(dpy) {}
  71.     MsgChange $msg(id)
  72.  
  73.     return 1
  74. }
  75.  
  76. proc Pgp_Old_ExtractKeys { path } {
  77.  
  78.     Exmh_Debug "Pgp_Old_ExtractKeys $path"
  79.  
  80.     # decide which version to use / implicitely checks for pgp enabled
  81.     if { [catch {Pgp_CheckVersion $path real v} err] } {
  82.         Exmh_Debug "<PGP> $err"
  83.         Exmh_Status "No version found! Perhaps there is no key."
  84.         return
  85.     }
  86.  
  87.     Exmh_Debug "<Pgp_Old_ExtractKeys> Pgp_Exec_ExtractKeys $v $path out"
  88.     Pgp_Exec_ExtractKeys $v $path out
  89.  
  90.     return 1
  91. }
  92.